<template>
  <div class="mylogin">
    <div class="mylogin-top">
        <img src="	https://css.mafengwo.net/mobile/images/header/logo200.png" alt="">
    </div>
    <van-form @submit="onSubmit">
      <van-cell-group inset>
        <van-field
          v-model="username"
          name="username"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]" 
          class="vanfield1"
        />
        <van-field
          v-model="password"
          type="password"
          name="password"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]" 
          class="vanfield2"
        />
      </van-cell-group>
      <div style="margin: 16px">
        <van-button round block type="primary" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
export default{
    data(){
        return{
            username:"",
            password:""
        }
    },
    methods:{
        onSubmit(values){
            console.log("values",values)
            if(this.username=="admin" && this.password=="123456"){
              localStorage.setItem("token","kcu")
              history.back()
            }else{
              alert("登录失败")
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.vanfield1,.vanfield2{
    border: 1px solid gray;
}
.mylogin{
    &-top{
        img{
            width: 100px;
            height: 30px;
            margin: 20px 128px;
        }
    }
}
</style>